app.preferences.rulerUnits = Units.MM;
var doc = documents.add(210,297);
var layer = doc.artLayers.add();
layer.kind = LayerKind.TEXT;
var textItem = layer.textItem;
textItem.contents="hello photoshop";

var rgb = app.foregroundColor.rgb;
rgb.red = 128;
rgb.blue = 0;
rgb.green = 128;
textItem.color = app.foregroundColor;
textItem.size = 40;
//alert(textItem.position);
textItem.position = [15, 12];